package com.manage.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateFormat {
	public static Date getLastDayOfMonth(String sj){//得到指定日期当月最后一天
		Calendar cal = Calendar.getInstance();
		try{
		cal.setTime(getDateByString(sj));
		
		cal.set(Calendar.DAY_OF_MONTH, 1);
		cal.roll(Calendar.DAY_OF_MONTH, -1);
		return cal.getTime();}
		catch(Exception e){
			return null;
		}
	}
	
	public static Date getDateByString(String sj){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		try{
			Date dt=sdf.parse(sj);
			return dt;
		}catch(Exception ex)
		{
			return null;
		}
	}
	
	public static Date getDateTimeByString(String sj){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try{
			Date dt=sdf.parse(sj);
			return dt;
		}catch(Exception ex)
		{
			return null;
		}
	}
	public static void main(int agrv,String[] agrs)
	{
		String a1 = "abc";
		String a2= "abc";
		System.out.println(a1==a2);
	}
	
}
